#ifndef DBUSTESTMODEL_HPP
#define DBUSTESTMODEL_HPP

#include <QAbstractItemModel>
#include "common.hpp"
#include <qdom.h>
class DbusTestModelItem;
class DbusTestModel : public QAbstractItemModel
{
    Q_OBJECT
public:
    explicit DbusTestModel(QObject *parent = nullptr);
    ~DbusTestModel();
signals:

public slots:
protected:
    DbusTestModelItem *root;

    // QAbstractItemModel interface
public:

    QVector<DbusTestModelItem *> getItemList();
    DbusTestModelItem *getItem(const QModelIndex &index);
    QModelIndex index(int row, int column, const QModelIndex &parent) const override;
    QModelIndex parent(const QModelIndex &child) const override;
    int rowCount(const QModelIndex &parent) const override;
    int columnCount(const QModelIndex &parent) const override;
    QVariant data(const QModelIndex &index, int role) const override;
    bool setData(const QModelIndex &index, const QVariant &value, int role) override;
    bool insertRows(int row, int count, const QModelIndex &parent) override;
    bool removeRows(int row, int count, const QModelIndex &parent) override;
    bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override;
    Qt::ItemFlags flags(const QModelIndex &index) const override;
    void append(DbusTestModelItem *item,const QModelIndex &index = QModelIndex());
    void insertItem(int position,DbusTestModelItem *item,const QModelIndex &index = QModelIndex());

    bool isSkip(const QModelIndex &index) const;
    void setSkip(const QModelIndex &index,bool isSkip);
    QModelIndexList getResultIndex(const int row);

    void importXML(QString context);
    QString exportXML();

    // QAbstractItemModel interface
public:
    QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
    bool moveColumns(const QModelIndex &sourceParent, int sourceColumn, int count, const QModelIndex &destinationParent, int destinationChild) override;
    inline int getColumnId(int index) const;
    inline int getColumnIndex(int id) const;
    QVariant getHeader(int id) const
    {
        switch (id) {
        case 0:
            return "Skip";
            break;
        case 1:
            return "category";
            break;
        case 2:
            return "method";
            break;
        case 3:
            return "param type";
            break;
        case 4:
            return "parameter";
            break;
        case 5:
            return "Addr";
            break;
        case 6:
            return "Service";
            break;
        case 7:
            return "Path";
            break;
        case 8:
            return "Interface";
            break;
        case 9:
            return "Result";
            break;
        case 10:
            return "start";
            break;
        case 11:
            return "end";
            break;
        default:
            break;
        }
        return QVariant();
    }

private:
    QList<int> m_ColumnsId;
};





































#endif // DBUSTESTMODEL_HPP
